<html>
<head><meta charset="utf-8"><title>Another nice error · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html">Another nice error</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230639796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230639796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230639796">(Mar 17 2021 at 05:14)</a>:</h4>
<p>No idea if there is already an issue for this. I just got to the place where the only compiler output is:</p>
<div class="codehilite"><pre><span></span><code>error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
   --&gt; my-lib/src/lib.rs:127:10
    |
127 |     ) -&gt; Result&lt;T,  SomeError&gt;
    |
note: hidden type `impl Future` captures lifetime smaller than the function body
   --&gt; my-lib/src/lib.rs:127:10
    |
127 |     ) -&gt; Result&lt;T, SomeError&gt;
</code></pre></div>
<p>I have honestly no idea what is wrong and how to fix it. What I know is that I added some error variants which store <code>&amp;'static str</code> and which string to store is passed as an argument to the async function which generates that error. But a static lifetime should never be too short?</p>



<a name="230639873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230639873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230639873">(Mar 17 2021 at 05:15)</a>:</h4>
<p>The function has the signature:</p>
<div class="codehilite"><pre><span></span><code>async fn perform_transaction&lt;F, T&gt;(
        &amp;mut self,
        error_name: &amp;&#39;static str,
        payload: &amp;[u8],
        deserialize: F,
    ) -&gt; Result&lt;T, SomeError&gt;
    where
        F: FnOnce(&amp;[u8]) -&gt; Result&lt;T, SomeError&gt;,
        T: &#39;static
    {
    }
</code></pre></div>



<a name="230650228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230650228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230650228">(Mar 17 2021 at 07:53)</a>:</h4>
<p>That's pretty weird. It compiles if you change <code>error_name</code> to take <code>&amp;str</code> rather than <code>&amp;'static str</code></p>



<a name="230690988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230690988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230690988">(Mar 17 2021 at 13:38)</a>:</h4>
<p><span class="user-mention" data-user-id="204219">@Matthias247</span> do you have a standalone version of it?</p>



<a name="230692271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230692271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230692271">(Mar 17 2021 at 13:47)</a>:</h4>
<p>The error shows up if you just define a dummy struct and put it in an impl block.</p>



<a name="230694279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230694279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230694279">(Mar 17 2021 at 13:59)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=04402e008eb16d36dda83a29b474444b">playground</a></p>



<a name="230694544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230694544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230694544">(Mar 17 2021 at 14:00)</a>:</h4>
<p>ok, there are two fixes:</p>
<ul>
<li>use <code>'static</code> for both arguments (<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=44e5103a7954551e7f42c60d623f1a66">playground</a>)</li>
<li>use no <code>'static</code> (<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=b10969dc3b1b198b2ffc0347f67f360f">playground</a>)</li>
</ul>



<a name="230694614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230694614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230694614">(Mar 17 2021 at 14:01)</a>:</h4>
<p>presumably this has <em>something</em> to do with the region inference rules, I'm supposed to be reviewing those again soon</p>



<a name="230713823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Another%20nice%20error/near/230713823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Another.20nice.20error.html#230713823">(Mar 17 2021 at 15:52)</a>:</h4>
<p>This is <a href="https://github.com/rust-lang/rust/issues/63033">#63033</a>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>